package objekte;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class ASCIIGame extends JFrame implements KeyListener, ActionListener{
  JTextArea anzeige;
  Timer timer;

  public ASCIIGame(int breit, int hoch, int milli){
    timer=new Timer(milli, this);
    anzeige=new JTextArea(hoch, breit);
    anzeige.setLineWrap(true);
    anzeige.setEditable(false);
    anzeige.setFont(new Font("Courier", Font.BOLD, 20));
    anzeige.addKeyListener(this);
    //anzeige.setCaretPosition(breit/2);
    Container c=getContentPane();
    c.add(anzeige, BorderLayout.CENTER);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    pack();
    anzeige.requestFocusInWindow();//Tastatur hierher!
    setVisible(true);
  }

  public void actionPerformed(ActionEvent e){}
  public void keyPressed(KeyEvent e){}
  public void keyReleased(KeyEvent e){}
  public void keyTyped(KeyEvent e){
    char c=e.getKeyChar();
    if(c=='t'){
      timer.start();
      System.out.println("Timer gestartet.");
    }
    System.out.println("typed: "+c);
  }

  public static void main(String[] args) {
    ASCIIGame game=new ASCIIGame(40, 25, 1000);
  }
}